//
//  ScanShopViewController.m
//  ShoppingExperience
//
//  Created by LiYinDi on 15/8/7.
//  Copyright (c) 2015年 RuiBen. All rights reserved.
//

#import "ScanShopViewController.h"
#import "ItemDetailTableViewCell.h"
#import "UIImageView+WebCache.h"
@interface ScanShopViewController ()
{
    NSString *weightStr;
    NSString *cutGoldStr;
    NSString *processPriceStr;
    NSString *todayGoldPriceStr;
    
    NSInteger priceDetailCellTag;
    BOOL isOpened;
    BOOL chengSeListIsOpen;

     NSMutableArray *productImageArray;
    
    NSMutableArray *itemCodeArray;
    NSMutableArray *itemNameArray;
    NSMutableArray *itemWhereArray;
    NSMutableArray *itemPriceArray;
    NSMutableArray *itemUrlArray;
    NSMutableArray *itemWeightArray;
    
    NSMutableArray *itemSeriesNameArray;
    NSMutableArray *itemTypeNameArray;
    NSMutableArray *itemInDateArray;

}
@end

@implementation ScanShopViewController
-(void)viewWillAppear:(BOOL)animated
{
    productImageArray=[NSMutableArray array];
    itemCodeArray=[NSMutableArray array];
    itemNameArray=[NSMutableArray array];
    itemWhereArray=[NSMutableArray array];
    itemPriceArray=[NSMutableArray array];
    itemUrlArray=[NSMutableArray array];
    itemWeightArray=[NSMutableArray array];
    
    itemSeriesNameArray=[NSMutableArray array];
    itemTypeNameArray=[NSMutableArray array];
    itemInDateArray=[NSMutableArray array];

    _productImagePageControl.currentPageIndicatorTintColor = [UIColor blackColor];
    _productImagePageControl.pageIndicatorTintColor = [UIColor grayColor];
    _addToShopCartBtn.layer.borderColor=[[UIColor colorWithRed:210.0f/255.0f green:171.0f/255.0f blue:57.0f/255.0f alpha:1] CGColor];
    _addToShopCartBtn.layer.borderWidth= 1.0f;
    _addToShopCartBtn.layer.cornerRadius=3;
    
    [_shopCartBtn addTarget:self action:@selector(shopCartBtnClick) forControlEvents:UIControlEventTouchUpInside];
    // imageHeightArray=[NSMutableArray array];
    [_leftTableView setBackgroundColor:[UIColor clearColor]];
    [_rightScrollView setScrollEnabled:YES];
    [self requestItemDetail:_itemCodeStr];

}
-(IBAction)scanShopBackBtnClick
{
    if ([self.delegate respondsToSelector:@selector(scanShopBackClick)]) {
        
        [self.delegate scanShopBackClick];
    }
    
}
-(void)shopCartBtnClick
{
    if ([self.delegate respondsToSelector:@selector(scanShopShopCartClick)]) {
        
        [self.delegate scanShopShopCartClick];
    }
    
}

-(IBAction)addToShopCartClick:(id)sender
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [params setObject:_itemCodeStr forKey:@"ItemCode"];
        [params setObject:@"A" forKey:@"EditType"];
        
        //  NSLog(@"addToShopCartParams===%@",params);
        [HttpRequest requestData:@"Guide/EditShopCart" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    // NSLog(@"addToShopCart===%@",severDataDict.dataDict);
                    //                    if ([self.delegate respondsToSelector:@selector(productItemDetailShopCartClick)]) {
                    //
                    //                        [self.delegate productItemDetailShopCartClick];
                    //                    }
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
//                    UIViewController *controller=[[GlobalViewController alloc]init];
//                    [self.navigationController pushViewController:controller animated:YES];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                      [Global loginViewController:self noteStr:requestResultStr];
                      //  [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
    }
    
}

-(void)requestItemDetail:(NSString *)codeStr
{
    _styleNameLabel.text=@"";
    _seriesNameLabel.text=@"";
    _priceLabel.text=@"";
    _dateLabel.text=@"";
    _addressLabel.text=@"";
    _weightLabel.text=@"";
    _certIdLabel.text=@"";
    _securitycodeLabel.text=@"";
    _adverbNameLabel.text=@"";
    _neatNessNameLabel.text=@"";
    _shapeLabel.text=@"";
    _adverbQtyNameLabel.text=@"";
    _gramLabel.text=@"";
    _itemCodeLabel.text=@"";
    _seriesCodeLabel.text=@"";
    _typeNameLabel.text=@"";
    _designerLabel.text=@"";
    _cadDateLabel.text=@"";
    _itypeNameLabel.text=@"";
    _productNameLabel.text=@"";
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [params setObject:codeStr forKey:@"ItemCode"];
        [HttpRequest requestData:@"Product/ItemDetail" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    //    NSLog(@"tt121=%@",severDataDict.dataDict);
                    [Global hideProgressHUDInternal:self.view];
                    [itemUrlArray addObject:[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"ImageUrl"]];
                    [itemTypeNameArray addObject:[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"ItypeName"]];
                    [itemSeriesNameArray addObject:[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"SeriesName"]];
                    [itemInDateArray addObject:[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"InDate"]];
                    [itemWeightArray addObject:[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"Gram"]];
                    [itemPriceArray addObject:[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"Price"]];
                    [itemWhereArray addObject:[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"WhsName"]];
                    [itemNameArray addObject:[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"ItemName"]];
                    [itemCodeArray addObject:[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"ItemCode"]];
                    [_leftTableView reloadData];
                    if (itemCodeArray.count>0) {
                        NSIndexPath *ip= [NSIndexPath indexPathForRow:0 inSection:0];
                        [_leftTableView selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewScrollPositionBottom];
                    }

                    [productImageArray removeAllObjects];
                    for (UIView *v in _productImageScrollView.subviews) {
                        [v removeFromSuperview];
                    }
                NSMutableArray *productImgArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataItemImgs"]];
                    
                    for (int i = 0;i<[productImgArray count];i++) {
                        [productImageArray addObject:[[productImgArray objectAtIndex:i] objectForKey:@"ImageUrl"]];
                        //loop this bit
                        
                        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(250*i,0, 250, 250)];
                        [imageView setImageWithURL:[NSURL URLWithString:[[productImgArray objectAtIndex:i] objectForKey:@"ImageUrl"]]];
                        
                        [_productImageScrollView addSubview:imageView];
                        
                    }
                    _productImageScrollView.contentOffset = CGPointMake(0, 0);
                    
                    _productImageScrollView.contentSize = CGSizeMake(250*productImgArray.count,250);
                    _productImagePageControl.numberOfPages = productImgArray.count;
                    
                    _productImagePageControl.currentPage = 0;
                    
                    if ([[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"ItypeName"]!=[NSNull null]) {
                        _styleNameLabel.text=[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"ItypeName"];
                        
                       // [self resizeLabel:_styleNameLabel];
                        [Global resizeForLable:_styleNameLabel WithText:_styleNameLabel.text parentView:self.view];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"ItemName"]!=[NSNull null]) {
                        _seriesNameLabel.text=[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"ItemName"];
                       [Global resizeForLable:_seriesNameLabel WithText:_seriesNameLabel.text parentView:self.view];
                       // [self resizeLabel:_seriesNameLabel];
                        CGRect frame0=_seriesNameLabel.frame;
                        frame0.origin.x=_styleNameLabel.frame.origin.x+_styleNameLabel.frame.size.width+3;
                        _seriesNameLabel.frame=frame0;
                    }
                    
                    if ([[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"Price"]!=[NSNull null]) {
                        _priceLabel.text=[NSString stringWithFormat:@"¥%@",[Global floatConvertPercentile:[[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"Price"] floatValue]]];
                        
                      //  [self resizeLabel:_priceLabel];
                        [Global resizeForLable:_priceLabel WithText:_priceLabel.text parentView:self.view];
                        CGRect frame1=_weightTagLabel.frame;
                        frame1.origin.x=_priceLabel.frame.origin.x+_priceLabel.frame.size.width+10;
                        _weightTagLabel.frame=frame1;
                        
                        CGRect frame2=_weightLabel.frame;
                        frame2.origin.x=_weightTagLabel.frame.origin.x+_weightTagLabel.frame.size.width+3;
                        _weightLabel.frame=frame2;
                    }
                    
                    if ([[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"InDate"]!=[NSNull null]) {
                        _dateLabel.text=[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"InDate"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"WhsName"]!=[NSNull null]) {
                        
                        _addressLabel.text=[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"WhsName"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"Gram"]!=[NSNull null]) {
                        _weightLabel.text=[NSString stringWithFormat:@"%@g",[Global floatConvertPercentile:[[[severDataDict.dataDict objectForKey:@"DataItem"] objectForKey:@"Gram"] floatValue]]];
                    }
                    
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"CertId"]!=[NSNull null]) {
                        _certIdLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"CertId"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"Securitycode"]!=[NSNull null]) {
                        _securitycodeLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"Securitycode"];
                        
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"AdverbName"]!=[NSNull null]) {
                        _adverbNameLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"AdverbName"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"NeatNess"]!=[NSNull null]) {
                        
                        _neatNessNameLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"NeatNess"];
                    }
                    
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"Shape"]!=[NSNull null]) {
                        _shapeLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"Shape"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"AdverbQty"]!=[NSNull null]) {
                        _adverbQtyNameLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"AdverbQty"];
                    }
                    
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"Gram"]!=[NSNull null]) {
                        _gramLabel.text=[NSString stringWithFormat:@"%@g",[[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"Gram"]];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"ItemCode"]!=[NSNull null])
                    {
                        _itemCodeLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadDetail"] objectForKey:@"ItemCode"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"SeriesCode"]!=[NSNull null])
                    {
                        _seriesCodeLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"SeriesCode"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"SeriesName"]!=[NSNull null])
                    {
                        _typeNameLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"SeriesName"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"Designer"]!=[NSNull null])
                    {
                        _designerLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"Designer"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"CadDate"]!=[NSNull null])
                    {
                        
                        _cadDateLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"CadDate"];
                    }
                    if ([[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"ItypeName"]!=[NSNull null])
                    {
                        _itypeNameLabel.text=[[severDataDict.dataDict objectForKey:@"DataHeadInf"] objectForKey:@"ItypeName"];
                    }
                 NSMutableArray *mTagsArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLineLabel"]];
                    float height1=0.0;
                    for (int i=0; i<mTagsArray.count; i++) {
                        UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
                        CGRect rect=button.frame;
                        rect.size.height=32;
                        rect.size.width=90;
                        rect.origin.x=48+100*(i%6);
                        rect.origin.y=_cadDateLabel.frame.origin.y+_cadDateLabel.frame.size.height+20+46*(i/6);
                        button.frame=rect;
                        height1=height1+35;
                        // height1=rect.origin.y+32;//height1+rect.size.height*(i/6);
                        button.tag=9;
                        [button setBackgroundColor:[UIColor colorWithRed:245.0f/255.0f green:245.0f/255.0f blue:245.0f/255.0f alpha:1.0f]];
                        [button setTitle:[[mTagsArray objectAtIndex:i] objectForKey:@"LabelName"] forState:UIControlStateNormal];
                        [button setTitleColor:[UIColor colorWithRed:80.0f/255.0f green:80.0f/255.0f blue:80.0f/255.0f alpha:1.0f] forState:UIControlStateNormal];
                        button.layer.cornerRadius=5;
                        
                        [_rightScrollView addSubview:button];
                        
                    }
                    //  height1=_cadDateLabel.frame.origin.y+_cadDateLabel.frame.size.height+20+46;
                    // NSLog(@"%f",height1);
                    UILabel *stylePicLabel=[[UILabel alloc] init];
                    stylePicLabel.text=@"款式图片";
                    stylePicLabel.tag=9;
                    stylePicLabel.font=[UIFont fontWithName:@"Helvetica" size:14];
                    stylePicLabel.frame=CGRectMake(51, _cadDateLabel.frame.origin.y+_cadDateLabel.frame.size.height+height1+30, 60, 21);
                    stylePicLabel.textColor=[UIColor colorWithRed:80.0f/255.f green:80.0f/255.f blue:80.0f/255.f alpha:1.0f];
                    [_rightScrollView addSubview:stylePicLabel];
                    UILabel *lineLabel=[[UILabel alloc] init];
                    lineLabel.tag=9;
                    lineLabel.frame=CGRectMake(103, _cadDateLabel.frame.origin.y+_cadDateLabel.frame.size.height+height1+height1+40, 480, 1);
                    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0f/255.0f green:238.0f/255.0f blue:238.0f/255.0f alpha:1.0f]];
                    [_rightScrollView addSubview:lineLabel];
                    NSMutableArray * mImagesArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLineImage"]];
                    float height=20.0;
                    for (int i = 0; i <mImagesArray.count; i++){
                        UIImageView *imageView = [[UIImageView alloc] init]; //
                        [imageView setImageWithURL:[NSURL URLWithString:[[mImagesArray objectAtIndex:i ] objectForKey:@"ImageUrl"]]];
                        //获取图片的框架，得到长、宽
                        CGRect rect = imageView.frame;
                        imageView.tag=9;
                        //设置默认高度
                        rect.size.height =[[[mImagesArray objectAtIndex:i ] objectForKey:@"ImageHeigh"] floatValue]/2;
                        rect.origin.x=42;
                        rect.origin.y=stylePicLabel.frame.origin.y+stylePicLabel.frame.size.height+height;
                        height=height+rect.size.height;
                        //设置宽度
                        rect.size.width = 525;
                        //赋值
                        imageView.frame = rect;
                        // NSLog(@"imageview.frame.x===%f",imageView.frame.origin.x);
                        //        imageView.tag = i;
                        //ScrollView添加子视图
                        [_rightScrollView addSubview:imageView];
                    }
                    [_rightScrollView setScrollEnabled:YES];
                    [_rightScrollView setContentSize:CGSizeMake(0, (stylePicLabel.frame.origin.y+stylePicLabel.frame.size.height+height))];
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                     [Global loginViewController:self noteStr:requestResultStr];   
                     //   [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
    
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

{
    
    int currentPage = (_productImageScrollView.contentOffset.x - _productImageScrollView.frame.size.width
                       
                       / ([productImageArray count]+2)) / _productImageScrollView.frame.size.width + 1;
    
    // NSLog(@"%d",currentPage);
    
    if (currentPage==0) {
        
        [_productImageScrollView scrollRectToVisible:CGRectMake(250*productImageArray.count, 0, 250, 250) animated:NO];
        
    }
    
    else if (currentPage==([productImageArray count]+1)) {
        
        //如果是最后+1,也就是要开始循环的第一个
        
        [_productImageScrollView scrollRectToVisible:CGRectMake(250, 0, 250, 250) animated:NO];
        
    }
    
}


- (void)scrollViewDidScroll:(UIScrollView *)sender

{
    CGFloat pageWidth = sender.frame.size.width;
    int page = floor((sender.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
    _productImagePageControl.currentPage = page;
    //    int page = _productImageScrollView.contentOffset.x/250-1;
    //    
    //    _productImagePageControl.currentPage = page;
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
        
        return 120;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   
        
        static NSString * const  leftIdentifier = @"leftIdentifier";
        ItemDetailTableViewCell *cell=( ItemDetailTableViewCell *)[tableView dequeueReusableCellWithIdentifier: leftIdentifier];
        if (cell==nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"ItemDetailTableViewCell" owner:self options:nil];
            cell = [array objectAtIndex:0];
        }
        cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame] ;
        cell.selectedBackgroundView.backgroundColor = [UIColor clearColor];
        //     NSIndexPath *indexPath1= [NSIndexPath indexPathForRow:_selectID inSection:indexPath.section];
        //       // if (indexPath.row==0) {
        //            [tableView selectRowAtIndexPath:indexPath1 animated:NO scrollPosition:UITableViewScrollPositionNone];
        // }
        if (itemUrlArray.count>0) {
            if ([itemUrlArray objectAtIndex:indexPath.row]!=[NSNull null]&&[[itemUrlArray objectAtIndex:indexPath.row] length]>0) {
                [ cell.productImageView setImageWithURL:[NSURL URLWithString:[itemUrlArray objectAtIndex:indexPath.row] ]];
            }
            else
            {
            [cell.productImageView setImage:[UIImage imageNamed:@"zhanweitu_.png"]];
            }
        }
        if (itemNameArray.count>0) {
            if ([itemNameArray objectAtIndex:indexPath.row]!=[NSNull null]) {
                cell.productNameLabel.text=[NSString stringWithFormat:@"%@ %@",[itemCodeArray objectAtIndex:indexPath.row],[itemNameArray objectAtIndex:indexPath.row]];//[_itemNameArray objectAtIndex:indexPath.row];
            }
        }
        if (itemPriceArray.count>0) {
            if ([itemPriceArray objectAtIndex:indexPath.row]!=[NSNull null]) {
                cell.productPriceLabel.text=[NSString stringWithFormat:@"¥%@",[Global floatConvertPercentile:[[itemPriceArray objectAtIndex:indexPath.row] floatValue]]];
            }
        }
        //    if(_itemWhereArray.count>0)
        //
        //    {
        //        cell.stockAddressLabel.text=[_itemWhereArray objectAtIndex:indexPath.row];
        //    }
        if (itemWeightArray.count>0) {
            if ([itemWeightArray objectAtIndex:indexPath.row]!=[NSNull null]) {
                cell.productWeightLabel.text=[NSString stringWithFormat:@"%0.02fg",[[itemWeightArray objectAtIndex:indexPath.row] floatValue]];
            }
             [Global resizeForLable:_weightLabel WithText:_weightLabel.text parentView:self.view];
          //  [self resizeLabel:_weightLabel];
            CGRect frame=cell.productPriceLabel.frame;
            frame.origin.x=cell.productWeightLabel.frame.origin.x+cell.productWeightLabel.frame.size.width+12;
            cell.productPriceLabel.frame=frame;
        }
        
        return cell;
   
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
